package liangtWorkSpace.base.ifElse;

/**
 * @ClassName SwitchCaseBase
 * @Description : SwitchCaseBase基础示例
 * @Author : LiangT
 * @Date : 2020/5/15 12:48
 */
public class SwitchCaseBase {
    public int calculateUsingSwitch(int a, int b, String operator) {
        int result = 0;
        switch (operator) {
            case "add":
                result = a + b;
                break;
            case "multiply":
                result = a * b;
                break;
            case "divide":
                result = a / b;
                break;
            case "subtract":
                result = a - b;
                break;
            case "modulo":
                result = a % b;
                break;
            default:
                result = Integer.MIN_VALUE;
        }
        return result;
    }
}
